<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue</title>
    <link rel="stylesheet" href="../../css/common.css">
</head>

<body>
    <div id="app">
        <div>
            <input type="number" v-model.trim="phone" @input="searchDebounce">
            <button @click="searchDebounce">查找</button>
        </div>
        <input type="text" v-model="list">
    </div>

    <script src='../../js/common.js'></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                phone: 123,
                list: [],
                allList: [1, 2, 3, 4, 5, 6, 7, 8, 9]
            },
            created() {
                this.searchDebounce = _.debounce(() => this.search(), 500)
            },
            methods: {
                search() {
                    console.log('ok')
                    if (this.phone) {
                        this.list = this.allList.filter(item => String(this.phone).includes(item))
                    } else {
                        this.list = this.allList
                    }
                }
            }
        })
    </script>
</body>

</html>